#include <iostream>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>

using std::cout;
using std::endl;


int main(int args, char *argv[])
{
    struct hostent *host = gethostbyname(argv[1]);
    printf("真实名称: %s\n其他别名：\n", host->h_name);

    for(int i{}; host->h_aliases[i] != nullptr; i++){
        printf("%s\n", host->h_aliases[i]);
    }

    printf("其他ip: \n");
    char buf[100]{};
    for(int i{}; host->h_addr_list[i] != nullptr; i++){
        inet_ntop(host->h_addrtype, host->h_addr_list[i], buf, sizeof(buf));
        printf("%s\n", buf);
        bzero(buf, 100);
    }

    return 0;
}